using System.Net;
using LiteNetLib.Utils;

namespace Game
{
	public struct LJPeers : INetSerializable
	{
		public IPEndPoint[] endpoints;

		public static implicit operator LJPeers(IPEndPoint[] endpoints)
		{
			LJPeers result = default(LJPeers);
			result.endpoints = endpoints;
			return result;
		}

		public void Deserialize(NetDataReader reader)
		{
			endpoints = new IPEndPoint[reader.GetInt()];
			for (int i = 0; i < endpoints.Length; i++)
			{
				endpoints[i] = reader.GetNetEndPoint();
			}
		}

		public void Serialize(NetDataWriter writer)
		{
			writer.Put(endpoints.Length);
			IPEndPoint[] array = endpoints;
			foreach (IPEndPoint endPoint in array)
			{
				writer.Put(endPoint);
			}
		}
	}
}
